import { ref } from 'vue'
import { EDialogType } from '../utils/projectTable'

export default function useShowDialog() {
  const show = ref(false)

  const optionItem = ref(null)

  const dialogType = ref<EDialogType>(EDialogType.EVENT_COUNT)

  function changeShow(newShow: boolean) {
    show.value = newShow
  }

  function changeDialogType(type: EDialogType) {
    dialogType.value = type
  }

  function close() {
    show.value = false
    optionItem.value = null
  }

  function handleClick(item: Record<string, any>) {
    optionItem.value = item
    changeShow(true)
  }

  return {
    show,
    changeShow,
    close,
    handleClick,
    optionItem,
    dialogType,
    changeDialogType,
  }
}
